package com.firmboy.service;

import com.firmboy.dao.CourseRepository;
import com.firmboy.model.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by CHJ on 2016/12/19.
 */
@Service
public class CourseService {
    @Autowired
    private CourseRepository courseRepository;

    @Transactional(propagation = Propagation.REQUIRED)
    public void save(Course course){
        courseRepository.save(course);
    }


    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Course> findAll(){
        return courseRepository.findAll();
    }
}
